/**
 * 模型ToolbarItem截图插件
 */
// @gum.Command([gum.Keys.Ctrl, gum.Keys.Shift, gum.Keys.H], gum.SystemType.ST_3D, gum.WorkMode.Painter)
// class PrintCommand implements gum.ICommand {
//   public constructor() {
//     const scope = this;
//     let api: gum.IApi;
//     scope.initialize = function (_api: gum.IApi) {
//       api = _api;
//     };

//     scope.do = function () {
//       api.UI.trigger({
//         pid: '2c2f3cf8e74f9dc6e085f44005d77aa9',
//         eventType: gum.PluginEventType.Command
//       });
//     };
//     // scope.dispose = function () {
//     //     scope.do = gum.noop;
//     //     scope.dispose = noop;
//     // };
//   }
//   public initialize: (api: gum.IApi) => void;
//   public do: () => void;
//   public dispose: () => void;
// }
// @gum.Plugin(gum.SystemType.ST_3D)
// export class PrintPlugin implements gum.IPlugin {
//   public readonly id: string;
//   public workMode: gum.WorkMode;
//   public toolbarItems: gum.IToolbarItem[];
//   public _button: gum.IToolbarItem;
//   public constructor() {
//     this.id = '2c2f3cf8e74f9dc6e085f44005d77aa9';
//     this.workMode = gum.WorkMode.Painter;
//     this._button = {
//       label: '视图',
//       enable: true,
//       icon: '../../../assets/images/icons-camera.png',
//       command: PrintCommand
//     };
//     this.toolbarItems = [this._button];

//     this.initialize = function (api: gum.IApi) {
//       this.willHandleEventExclusively = function (event: gum.IPluginEvent) {
//         if (event.eventType === gum.PluginEventType.Command) {
//           api['3D'].dispatchControlEvent({ type: 'printClick' });
//         }
//       };
//     };
//     this.dispose = () => {
//       this.toolbarItems.length = 0;
//       this.toolbarItems = null;
//       this._button = null;
//     };
//   }
//   public initialize: (api: gum.IApi) => void;
//   public dispose: () => void;
//   public active: () => void;
//   public willHandleEventExclusively: (event: gum.IPluginEvent) => void;
// }
/**
 * 模型ToolbarItem标记插件
 */
// @gum.Command([gum.Keys.Ctrl, gum.Keys.Shift, gum.Keys.H], gum.SystemType.ST_3D, gum.WorkMode.Painter)
// class MarkCommand implements gum.ICommand {
//   public constructor() {
//     let api: gum.IApi;
//     this.initialize = function (_api: gum.IApi) {
//       api = _api;
//     };

//     this.do = function () {
//       api.UI.trigger({
//         pid: '2c2f3cf8e74f9dc6e085f44005d77aa8',
//         eventType: gum.PluginEventType.Command
//       });
//     };
//   }
//   public initialize: (api: gum.IApi) => void;
//   public do: () => void;
//   public dispose: () => void;
// }
// @gum.Plugin(gum.SystemType.ST_3D)
// export class MarkPlugin implements gum.IPlugin {
//   public readonly id: string;
//   public workMode: gum.WorkMode;
//   public toolbarItems: gum.IToolbarItem[];
//   public _button: gum.IToolbarItem;
//   public isActive = false;
//   public constructor() {
//     this.id = '2c2f3cf8e74f9dc6e085f44005d77aa8';
//     this.workMode = gum.WorkMode.Painter;
//     this._button = {
//       label: '标记',
//       enable: true,
//       icon: '../../assets/dist/images/icons-mark.png',
//       command: MarkCommand,
//       check: 2
//     };
//     this.toolbarItems = [this._button];

//     this.initialize = function (api: gum.IApi) {

//       this.isActive = false;
//       this.willHandleEventExclusively = function (event: gum.IPluginEvent) {

//         if (event.eventType === gum.PluginEventType.Command) {
//           api['3D'].dispatchControlEvent({ type: 'markClick' });
//         }
//       };
//     };
//     this.dispose = () => {
//       this.isActive = false;
//       this.toolbarItems.length = 0;
//       this.toolbarItems = null;
//       this._button = null;
//     };
//   }
//   public initialize: (api: gum.IApi) => void;
//   public dispose: () => void;
//   public active: () => void;
//   public willHandleEventExclusively: (event: gum.IPluginEvent) => void;
// }
// 进度展开收缩功能
@gum.Command([gum.Keys.Ctrl, gum.Keys.Shift, gum.Keys.H], gum.SystemType.ST_3D, gum.WorkMode.Painter)
export class ScheduleCommand implements gum.ICommand {
  public constructor() {
    let api: gum.IApi;
    this.initialize = function (_api: gum.IApi) {
      api = _api;
    };

    this.do = function () {
      api.UI.trigger({
        pid: '2c2f3cf8e74f9dc6e085f44005d77aa8',
        eventType: gum.PluginEventType.Command
      });
    };
  }
  public initialize: (api: gum.IApi) => void;
  public do: () => void;
  public dispose: () => void;
}
const enum CheckState {
  UNCHECK = 0,
  CHECK = 1,
  INDETERMINATE = 2
}
@gum.Plugin(gum.SystemType.ST_3D)
export class SchedulePlugin implements gum.IPlugin {
  public readonly id: string;
  public workMode: gum.WorkMode;
  public toolbarItems: gum.IToolbarItem[];
  public _button: gum.IToolbarItem;
  public isActive = false;
  private api: gum.IApi;
  public constructor() {
    this.id = '2c2f3cf8e74f9dc6e085f44005d77aa8';
    this.workMode = gum.WorkMode.Painter;
    this._button = {
      label: '4D',
      enable: true,
      icon: '../../../assets/images/project/4D.png',
      command: ScheduleCommand,
      check: 0
    };
    this.toolbarItems = [this._button];
    let _check = CheckState.UNCHECK;
    let that = this;
    Object.defineProperty(this._button, 'check', {
      set: function (c) {
        if (c !== _check) {
          _check = c
          that.api['3D'].dispatchControlEvent({ type: 'scheduleClick' });
        }
      },
      get: function () {
        return _check;
      }
    });
    this.initialize = function (api: gum.IApi) {
      this.isActive = false;
      this.api = api;
      this.willHandleEventExclusively = function (event: gum.IPluginEvent) {
        if (event.eventType === gum.PluginEventType.Command) {
          api['3D'].dispatchControlEvent({ type: 'scheduleClick' });
        }
      };
    };
    this.dispose = () => {
      this.isActive = false;
      this.toolbarItems.length = 0;
      this.toolbarItems = null;
      this._button = null;
    };
  }
  public initialize: (api: gum.IApi) => void;
  public dispose: () => void;
  public active: () => void;
  public willHandleEventExclusively: (event: gum.IPluginEvent) => void;
}
